const loaderUtils = require('loader-utils');

module.exports = function(source) {
  // 兼容webpack5和老版本
  const options = this.getOptions ? this.getOptions() : loaderUtils.getOptions(this) || {};
  const prefix = options.prefix || 'demo-';
  // 匹配 .className 的正则
  return source.replace(/\.(\w[\w-]*)/g, (match, p1) => `.${prefix}${p1}`);
}; 